<template>
  <div >
    <!-- 表格部分 -->
    <el-table :data="tableData" style="width: 100%; margin-top: 20px">
      <el-table-column label="序号" type="index" width="60" align="center" />
      <el-table-column prop="车牌号" label="车牌号" min-width="150" />
      <el-table-column prop="进入时间" label="入场时间" min-width="200" />
      <el-table-column prop="离开时间" label="出场时间" min-width="200" />
      <el-table-column prop="费用" label="产生费用" min-width="200" />
      <el-table-column prop="状态" label="状态" min-width="100" >
        <template #default="scope">
          <span style="color: var(--el-color-primary);">{{ scope.row.状态 === 'temporary' ?'临时车':'' }}</span>
          <span style="color: var(--el-color-primary);">{{ scope.row.状态 === 'long_term' ?'长期车':'' }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script >
import {getLicensePlates} from "@/api/Approach";
export default {
  name: "Approach",
  data() {
    return {
      tableData: [], // 添加 tableData 数据
    };
  },
  methods: {
   queryData(){
    const ID = localStorage.getItem("userId");
    getLicensePlates(ID).then((res) => {
      this.tableData = res.data; // 更新表格数据
    }).catch((err) => {
      console.error("获取数据失败", err);
      this.$message.error("获取数据失败");
    });
   }
  },
  created() {
    this.queryData()
  },
};
</script>

<style scoped>
</style>
